import { useState, useEffect, Component } from "react";

type Comp1Props = {
  data: { a: number; b: number };
};

class Comp1 extends Component<Comp1Props> {
  state = { message: `hello ，world!` };
  sayHello = () => {
    this.setState({ message: "hello, my name is alien" });
    console.log("say hello", this);
    this.props.data.a -= 1;
  };

  render() {
    const pdata = this.props.data;
    return (
      <fieldset onClick={this.sayHello}>
        <legend>子组件1</legend> {this.state.message} {pdata.a} - {pdata.b}
      </fieldset>
    );
  }
}
export default Comp1;
